/**
 * 
 * Created On:June 18, 2009 3:00:33 PM
 */
package util;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;

/**
 * @author Neev Information Technologies Pvt. Ltd.
 * 
 * <p>
 * <a href="SpringContext.java.html"><i>View Source</i></a>
 * </p>
 * 
 * This is a utility class to lookup Spring managed beans. It abstracts loading
 * the application context. InitServlet Initializes this class.
 */
public class SpringContext implements BeanFactoryAware {

	private static BeanFactory beanFactory = null;
	private static Logger cat = Logger.getLogger(SpringContext.class.getName());

	/**
	 * This method is called by spring at startup. No other class sould call
	 * this.
	 */
	public void setBeanFactory(BeanFactory beanFactory) {
		cat.info("Beanfactory set.");
		this.beanFactory = beanFactory;
	}

	/**
	 * Retuns a spring managed bean with the specified name.
	 */
	public static Object getBean(String name) {
		return beanFactory.getBean(name);
	}
}
